import { useSelector, useDispatch } from 'react-redux'
import { increment, decrement, incrementByAmount } from '../store/counterSlice'
import { useState } from 'react';
const About = () => {
    const count = useSelector(state => state.counter.value)
    const dispatch = useDispatch()
    const [number, setNumber] = useState(0)

    return (
        <div>
            <h1>About Current count: {count}</h1>
            <button onClick={() => dispatch(increment())}>+</button>
            <button onClick={() => dispatch(decrement())}>-</button>

            <div>
                <input
                    type="number"
                    value={number}
                    onChange={(e) => setNumber(Number(e.target.value))}
                />
                <button onClick={() => dispatch(incrementByAmount(number))}>
                    增加指定数值
                </button>
            </div>
        </div>
    )
}
export default About